<h3><%= t(".title") %></h3>

<p class="lead"><%= t(".description") %></p>

<table class="table table-striped">
  <tr>
    <th><%= User.human_attribute_name(:username) %></th>
    <th><%= User.human_attribute_name(:email) %></th>
    <%= content_tag :th, User.human_attribute_name(:auth_uid) if SiteSettings.oidc_enabled? %>
    <%= content_tag :th, t(".local") if SiteSettings.federation_enabled? %>
    <%= content_tag :th, t(".fediverse_address") if SiteSettings.federation_enabled? %>
    <th><%= User.human_attribute_name(:roles) %></th>
    <th></th>
  </tr>
  <% @users.each do |user| %>
    <tr class="<%= user.entity&.approved? ? "" : "table-info" %>">
      <td>
        <%= Icon(icon: "hourglass", label: "") unless user.entity&.approved? %>
        <%= user.entity.is_a?(User) ? user.entity&.username : user.username %>
      </td>
      <td><%= user.entity.is_a?(User) ? masked_email(user.entity&.email) : nil %></td>
      <%= content_tag :td, (user.entity&.auth_uid ? "✅" : "❌") if SiteSettings.oidc_enabled? %>
      <%= content_tag :td, (user.local? ? "✅" : "❌") if SiteSettings.federation_enabled? %>
      <%= content_tag :td, user.at_address if SiteSettings.federation_enabled? %>
      <td><%= user.entity&.roles&.map(&:name)&.join(", ") if user.entity&.is_a?(User) %></td>
      <td><%= link_to safe_join([Icon(icon: "search", label: t(".view")), t(".view")], " "), settings_user_path(user.entity), class: "btn btn-primary" if user.entity %></td>
    </tr>
  <% end %>
</table>

<%= link_to t(".new"), new_settings_user_path, class: "btn btn-primary" if policy(:user).new? %>
